<extend name="Layout/ins_page" />
<block name="content">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php if (!session_id()) session_start();date_default_timezone_set('PRC'); ?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>授权列表</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <link href="/sap/demo.css" rel="stylesheet" type="text/css" />
    <script src="/sap/scripts/boot.js" type="text/javascript"></script>
	<style>
	
	</style>
    
</head>
<body >


 <fieldset id="fd1" style="border: 1px solid #e5e5e5;height: 50px">
        <legend><span></span></legend>
        <div  id='fm1'>
        <div class="fieldset-body">
                 
 <!--          买家姓名： <input id="U_Cstname"  name="U_Cstname" class="mini-textbox" enabled='false' />
          手机号码： <input  id="U_Phone"  name="U_Phone" class="mini-textbox"  value=""enabled='false' /><br/><br/> -->
         &nbsp;&nbsp;订单号： <input  id="orderId"  name="orderId" class="mini-textbox"  value="" />        
          <a class="mini-button" onclick="search" enabled="" >&nbsp;&nbsp;查询&nbsp;&nbsp;</a>   
          <br/>
        </div>
          </div>
    </fieldset>
  
   
    <div id="tabs1" class="mini-tabs" activeIndex="0" style="width:100%;margin-top: 5px;overflow:auto;" plain="false"
    buttons="#tabsButtons"
>
    <div title="订单信息" >
   
    <div id="datagrid1" class="mini-datagrid" style="height:300px;width: 100%;" 
        url="" idField="id"
        allowResize="true" 
        allowCellEdit="true" allowCellSelect="true" multiSelect="true"
        allowCellValid="true" oncellvalidation="onCellValidation" showPager='false'>
        <div property="columns">
            
            <div field="orderid" vtype=""   headerAlign="center"  >订单号
                <input property="" class="mini-textbox" style="width:100%;" />
            </div>  
            
             <div field="goodsspu" vtype=""   headerAlign="center"  >物料编号
                <input property="" class="mini-textbox" style="width:100%;" />
            </div> 
            
              <div field="goodsname" vtype=""   headerAlign="center"  >物料名称
                <input property="" class="mini-textbox" style="width:100%;" />
            </div>    
            
             <div field="customer"    headerAlign="center"  >客户姓名
                <input property="" class="mini-textbox" style="width:100%;" />
            </div>    
            
             <div field="tel"    headerAlign="center"  >客户电话
                <input property="" class="mini-textbox" style="width:100%;" />
            </div>           
            
            <div field="address"    headerAlign="center"  >客户地址
                <input property="" class="mini-textbox" style="width:100%;" />
            </div>   
            
            
              <div field="expcom"    headerAlign="center"  >快递公司
                <input property="" class="mini-textbox" style="width:100%;" />
            </div> 
            
             <div field="expno"    headerAlign="center"  >快递单号
                <input property="" class="mini-textbox" style="width:100%;" />
            </div> 
            
             <div field="senduser"    headerAlign="center"  >工单对接人
                <input property="editor" class="mini-textbox" style="width:100%;" />
            </div> 
            
            
      
        </div>
    </div>
    
    
    </div>
    <!-- <div title="Tab2" iconCls="" >
        2
    </div> -->
</div>

  <div id='editForm1'>
     流转原因：
 
 	<textarea  class="editor" id="remarks" name="remarks" class="col-xs-12"></textarea>
 
    <br />
     
    <a class="mini-button" onclick="save" enabled="" id='update-bt' style="">&nbsp;&nbsp;添加&nbsp;&nbsp;</a>
    <a class="mini-button" onclick="clear" enabled="" id='colse-tb'>&nbsp;&nbsp;取消&nbsp;&nbsp;</a>
  </div>
</body>
<script type="text/javascript">
        mini.parse();
        var grid = mini.get("datagrid1");
        var Genders = [{'id':'1','text':'未完成'},{'id':'2','text':'已转到售后'},{'id':'3','text':'已完成'}];
        function onGenderRenderer(e) {
            for (var i = 0, l = Genders.length; i < l; i++) {
                var g = Genders[i];
                if (g.id == e.value) return g.text;
            }
            return "";
        }
        ///////////////////////////////////////////////////////
		var db = new mini.DataBinding();
        db.bindForm("editForm1", grid);
        function removeRow() {
            var rows = grid.getSelecteds();
            if (rows.length > 0) {
                grid.removeRows(rows, true);
            }
        }

        function getOrdermsg(){
			var row = grid.getSelected();
			var orderId = mini.get("orderId").getValue();
		
			 $.ajax({
	                url: "/sale/getOrderAjax",
	                data: { orderId: orderId },
	                type: "post",
	                dataType:'json',
	                success: function (data) {
		           		
	                	row.U_Phone=data.U_Phone;
	                	row.U_Cstname=data.U_Cstname;
	                	row.U_Address=data.U_address;
	                	row.U_UserCode='<?php echo $_SESSION['emp_no']?>';
	                	row.U_UserName='<?php echo $_SESSION['user_name']?>';
	                	grid.setSelected(row);
	                	grid.selects(0);
	                	
	                },
	                error: function (jqXHR, textStatus, errorThrown) {
	                    alert(jqXHR.responseText);
	                }
	            });

         }


        grid.on("cellclick", function (e) {
            var record = e.record,
                column = e.column,
                field = e.field,
                value = e.value;
            	if (field == "U_AccuDate") {
            		getOrdermsg();
          		  }

            });
        function save() {
            var data = grid.getData();
       
            if(data==''){
            	 mini.alert('无订单数据');
            	 return ;
            }
            
             var json = mini.encode(data);
             var remarks = tinyMCE.activeEditor.getContent() ;
             if(remarks==''){
            	 mini.alert('请填写流转原因');
            	 return ;
             }

            mini.mask({
                el: document.body,
                cls: 'mini-mask-loading',
                html: '保存中...'
            });
            $.ajax({
                url: "/wkorder/docreate",
                data: { data: json,remarks:remarks},
                type: "post",
                success: function (text) {
                   if(text>0){
                	    mini.unmask(document.body);
                	    tinyMCE.activeEditor.setContent(' ') ;
						mini.alert('新增成功');
						clear();
                   }
                },
                error: function (jqXHR, textStatus, errorThrown) {
                    alert(jqXHR.responseText);
                }
            });
        }

        function search(){
		
			var orderId = mini.get('orderId').getValue();
			if(orderId==''){
			   mini.alert('必须输入订单号');
			   return ;
		    }

			   mini.mask({
	               el: document.body,
	               cls: 'mini-mask-loading',
	               html: '数据加载中....'
	           }); 
	            
			
      	  $.ajax({
              url: "/wkorder/queryOrder",
              data: { orderid: orderId },
              type: "post",
              dataType:'json',
              success: function (data) {
            	  mini.unmask(document.body);
                  grid.setData(data.data);
                  grid.validateRow(newRow);   //加入新行，马上验证新行
                
              },
              error: function (jqXHR, textStatus, errorThrown) {
                  alert(jqXHR.responseText);
              }
          });

            }
        function clear(){
         	 grid.setData(null);
            mini.get('remarks').setValue("");
            mini.get('orderId').setValue("");
           }

    </script>
</html>
</block>
